import Vue from 'vue'
import Router from 'vue-router'

import home from "../components/home/home.vue"
import discover from "../components/discover.vue"
import setting from "../components/setting.vue"

import Location from "../components/home/location.vue"
import weather from "../components/home/weather.vue"
import detail from "../components/home/detail.vue"


Vue.use(Router)

export default new Router({
  routes: [
  	{
  		path:"/",
  		redirect:"/home"//重定向，访问/时跳转到/home
  	},
    {
    	name:"home",
    	path:"/home",
    	//alias:"/",//别名，访问/时也会加载home组件
    	component:home,
    	children:[
    		{
    			name:"location",
    			path:"location",
    			component:Location
    		},
    		{
    			name:"weather",
    			path:"weather",
    			component:weather
    		},
    		{
    			//title&index为给子页面传的值(必须有传值才能显示子页面)
    			name:"detail",
    			path:"detail/:title/:index",
    			component:detail
    		}
    	]
    },
    {
    	name:"discover",
    	path:"/discover",
    	component:discover
    },
    {
    	name:"setting",
    	path:"/setting",
    	component:setting
    },
    {
    	path:"**",//匹配所有路径，放在最后是匹配剩余错误路径
    	//component:可以写个404的组件
    	redirect:"/home"//也可以重定向到/home
    }
  ]
})
